﻿@model Gtkj.CMS.Model.Customer
@{
    ViewBag.Title = "GetCustomerDetail";
    Layout = "~/Views/Shared/Master.cshtml";
}

<div class="page-content">
    <!-- BEGIN PAGE HEADER-->
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li>
                <a href="/Home/Main">首页</a>
                <i class="fa fa-angle-double-right"></i>
            </li>
            <li>
                <a href="/Home/CustomerList">客户列表</a>
                <i class="fa fa-angle-double-right"></i>
            </li>
            <li>
                <span>查看详情</span>
            </li>
        </ul>
    </div>
    <!-- BEGIN PAGE TITLE-->
    <h3 class="page-title">
        查看详情
        <small></small>
    </h3>
    <!--biaoge-->
    <div class="portlet light ">
        <div class="portlet-title tabbable-line">
            <div class="caption"><i class="icon-settings font-yellow-casablanca"></i><span class="caption-subject bold font-yellow-casablanca">客户信息</span></div>
            <a class="btn btn-success pagin_ri" href="javascript:;" onclick="history.go(-1)"><span class="icon-action-undo" aria-hidden="true" style="float:left; margin-top:3px; margin-right:4px"></span> 返回</a>
        </div>
        <!-- END PAGE TITLE-->
        <div class="search_1" style="padding-bottom:5px">
            <!-- END PAGE TITLE-->
            <div class="form-horizontal">
                <div class="media-body" style="overflow:visible">
                    <div class="row">
                        <div class="col-md-6 col-sm-6">
                            <div class="form-group m_bot10">
                                <label class="control-label col-md-4 col-sm-4">姓名：</label>
                                <div class="col-md-8 col-sm-8">
                                    <p class="form-control-static"> <a href="javascript:;" id="username" data-type="text" data-pk="1" data-original-title="输入修改信息">@Model.Name</a></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 col-sm-6">
                            <div class="form-group m_bot10">
                                <label class="control-label col-md-4 col-sm-4">手机号码：</label>
                                <div class="col-md-8 col-sm-8">
                                    <p class="form-control-static"><a href="javascript:;" id="iphone" data-type="text" data-pk="1" data-original-title="输入修改信息"> @Model.Phone</a></p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6 col-sm-6">
                            <div class="form-group m_bot10">
                                <label class="control-label col-md-4 col-sm-4">性别：</label>
                                <div class="col-md-8 col-sm-8">
                                    @if (Model.Sex == true)
                                    {
                                        <p class="form-control-static"> 男 </p>
                                    }
                                    else
                                    {
                                        <p class="form-control-static"> 女 </p>
                                    }
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 col-sm-6">
                            <div class="form-group m_bot10">
                                <label class="control-label col-md-4 col-sm-4">年龄：</label>
                                <div class="col-md-8 col-sm-8">
                                    <p class="form-control-static"> @Model.Age </p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6 col-sm-6">
                            <div class="form-group m_bot10">
                                <label class="control-label col-md-4 col-sm-4">地址：</label>
                                <div class="col-md-8 col-sm-8">
                                    <p class="form-control-static"> @Model.Address</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 col-sm-6">
                            <div class="form-group m_bot10">
                                <label class="control-label col-md-4 col-sm-4">详情：</label>
                                <div class="col-md-8 col-sm-8">
                                    <p class="form-control-static"><a href="javascript:;" id="zhi" data-type="text" data-pk="1" data-original-title="输入修改信息">@Model.Details</a></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- END PAGE TITLE-->
        <div class="tabbable tabbable-tabdrop form_mag">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#tab1" data-toggle="tab">订单记录（手机号）</a>
                </li>
            </ul>
            <div class="tab-content">
                <!--阅读记录-->
                <div class="tab-pane active" id="tab1">
                    <div class="portlet-body">
                        <div class="table-scrollable_1 table-scrollable-borderless">
                            <table class="table table-striped table-hover table-checkable order-column dataTable no-footer table_ri bordered_bott table4">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>客户姓名</th>
                                        <th>手机号</th>
                                        <th>订购产品</th>
                                        <th>快递单号</th>
                                        <th>回访时间</th>
                                        <th>支付方式</th>
                                        <th>价格</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="tbody">

                                </tbody>
                            </table>
                        </div>
                        <div style="margin-bottom:50px;" id="fenye">
                            <button class="layui-btn layui-btn-xs" style="float:left" onclick="LastPage();">上一页</button>
                            <div style="padding:inherit;float:left;width:78px;height:38px;"><div style="margin-top:8px;text-align:center;" id="pagecounttext"></div></div>
                            <button class="layui-btn layui-btn-xs" style="float:left" onclick="NextPage();">下一页</button>
                            <div style="height:38px;width:500px;float:left;">
                                <div><span style="float:left;margin-left:10px;margin-top:8px;">跳转至</span></div>
                                <div style="height:38px;">
                                    <input type="text" id="pagecount" style="margin-left:20px;margin-top:7px; width:50px;" />
                                    <button class="" style="margin-left:20px;margin-top:7px; width:50px;" onclick="JumpPage();">确定</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var pageindex = 1;
    var pagecount;
    $(function () {
        pageindex = 1;
        GetPage();
    });
    function GetPage() {
        $.ajax({
            url: "/Home/GetOrderPage",
            data: {
                pageindex: pageindex,
                Phone:@Model.Phone
            },
            success: function (result) {
                if (result.totalcount > 0) {
                    var str = ToHtml(result.list);
                    $("#tbody").html('');
                    $("#tbody").html(str);
                    $("#pagecounttext").text(pageindex + "/" + result.pagecount);
                    pagecount = result.pagecount;
                    $("#fenye").show();
                } else {
                    $("#tbody").html('暂无数据');
                    $("#fenye").hide();
                }
            }
        });
    }
    function ChaXun() {
        pageindex = 1;
        GetPage();
    }
    function LastPage() {
        if (pageindex > 1) {
            pageindex--;
            GetPage();
        }
    }
    function NextPage() {
        if (pageindex < pagecount) {
            pageindex++;
            GetPage();
        }
    }
    function JumpPage() {
        var c = $("#pagecount").val();
        if (!isNaN(c) && c >= 1 && c <= pagecount) {
            pageindex = c;
            GetPage();
        }
    }

    function ToHtml(data) {
        var str = "";
        $.each(data, function (i, item) {
            str += "<tr><td>" + (i + 1) + "</td>";
            str += "<td>" + item.CustomerName + "</td>";
            str += "<td>" + item.Phone + "</td>";
            str += "<td>" + item.GoodName + "</td>";
            str += "<td>" + item.ExpressNumber + "</td>";
            str += "<td>" + item.VisitTime + "</td>";
            str += "<td>" + item.PayWay + "</td>";
            str += "<td>" + item.Price + "</td>";
            str += '<td><div class="btn-group"><button class="btn btn-default btn-xs btn_ri" onclick="GetById(' + item.Id + ');" type="button"><i class="fa fa-share"></i>查看</button>';
            str += '<div class="btn-group"><button class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" type="button" aria-expanded="false">';
            str += '<i class="fa fa-ellipsis-horizontal"></i>更多<i class="fa fa-angle-down"></i></button>';
            str += '<ul class="dropdown-menu pull-right dropdown_wid"><li><a href="javascript:;" onclick="UpdateById(' + item.Id + ');"><i class="fa fa-edit"></i> 修改 </a></li>';
            str += '<li><a href="javascript:;" onclick="FollowUp(' + item.Id + ');"><i class="fa fa-pencil"></i> 跟进 </a></li><li><a href="javascript:;" onclick="Delete(' + item.Id + ');"><i class="glyphicon glyphicon-trash"></i> 删除 </a></li></ul></div></div></td></tr>';
        })
        return str;
    }

    function ExportExcel() {
        $.ajax({
            url: "/Home/ExportExcel",
            data: {
                CreateTime: $("#CreateTime").val(),
                Phone: $("#Phone").val(),
                CName: $("#CName").val(),
                type: $("#type").val()
            },
            success: function (result) {
                if (result.success) {
                    window.open(result.url);
                } else {
                    layer.msg(result.msg, { icon: 2 });
                    console.log(result.res);
                }
            }
        });
    }

    function GetById(id) {
        window.location.href = "/Home/GetOrderById?id=" + id;
    }

    function UpdateById(id) {
        window.location.href = "/Home/GetOrderByIdToUpdate?id=" + id;
    }

    function FollowUp(id) {
        var url = '/Home/AddVisit?Id=' + id;
        layer.open({
            type: 2,
            title: false,
            shadeClose: true,
            shade: [0.5],
            maxmin: false, //开启最大化最小化按钮
            area: ['700px', '400px'],
            content: url
        });
    }

    //function Delete(id) {
    //    layer.confirm('请再次确认是否删除此订单', {
    //        btn: ['确定', '取消'] //按钮
    //    }, function () {
    //        $.ajax({
    //            url: "/Home/DeleteOrder",
    //            type: "post",
    //            data: { OrderId: id },
    //            success: function (result) {
    //                if (result.success) {
    //                    layer.msg('删除成功', { icon: 1 });
    //                    setTimeout("location.reload();", 1000);
    //                }
    //            }

    //        });
    //        }

    function Delete(id) {
        layer.confirm('请再次确认是否删除此订单？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                url: "/Home/DeleteOrder",
                type: "post",
                data: { OrderId: id },
                success: function (result) {
                    if (result.success) {
                        layer.msg('删除成功', { icon: 1 });
                        setTimeout("location.reload();", 1000)
                    }
                }

            });
        }, function () {

        });
    }
</script>